package bintree.heap;

import java.util.concurrent.ThreadLocalRandom;

public class MaxTest {
    public static void main(String[] args) {
        int[] arr=new int[]{15,17,19,13,22,16,28,30,41,62};
        MaxHeap heap = new MaxHeap(arr);
        heap.add(100);
        System.out.println(heap);
        int[] data=new int[10000];
        //随机数
        ThreadLocalRandom random = ThreadLocalRandom.current();
        for (int i = 0; i < data.length; i++) {
            data[i] = random.nextInt();
        }
        MaxHeap heap2 = new MaxHeap();
        for (int i = 0; i < data.length; i++) {
            heap2.add(data[i]);
        }
        for (int i = 0; i < data.length; i++) {
            data[i]=heap2.extractMax();
        }
        System.out.println(isSort(data));
    }

    //判断是否非缯
    public static boolean isSort(int[] arr){
        for (int i = 0; i < arr.length - 1; i++) {
            if (arr[i] < arr[i + 1]) {
                return false;
            }
        }
        return true;
    }
}
